import { useEffect,useState } from "react"
import request from "../utils/request"
import { Tabs} from "antd"

function List() {
  const [datalist,setDatalist] = useState([])
  const [listdetail,setListdetail] = useState({})
  useEffect(()=>{
    request.get('/user/getMasterSelfEssay',{
      params:{
        pageNum:1,
        pageSize:5
      }
    }).then(res=>{
      console.log(res)
      setDatalist(res.data.data)
    })
  },[])
  const showdetail = (id)=>{
    request.get('http://127.0.0.1:8087/user/getSelfEssayDetail',{
      params:{
        essayId:id
      }
    }).then(res=>{
      console.log(res)
       setListdetail(res.data.data)
    })
  }
  return (
    <div>
      <h1>列表页</h1>
      <ul>
        {
          datalist?.map(item=>(
            <li onClick={()=>showdetail(item.id)} key={item.id}>
              {item.title}
            </li>
          ))
        }
      </ul>
      <div>
         {
          listdetail?.title?
          <div>
            <p>{listdetail.show_content}</p>
          </div>
          :
          null
         }
      </div>
    </div>
  )
}

export default List